package cn.com.egova.erp.biz.impl;

import cn.com.egova.erp.biz.IStoreoperBiz;
import cn.com.egova.erp.dao.IEmpDao;
import cn.com.egova.erp.dao.IGoodsDao;
import cn.com.egova.erp.dao.IStoreDao;
import cn.com.egova.erp.dao.IStoreoperDao;
import cn.com.egova.erp.entity.Storeoper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 仓库操作记录业务逻辑类
 *
 * @author Administrator
 */
public class StoreoperBiz extends BaseBiz<Storeoper> implements IStoreoperBiz {

    private IStoreoperDao storeoperDao;
    private IEmpDao empDao;
    private IStoreDao storeDao;
    private IGoodsDao goodsDao;

    public void setStoreoperDao(IStoreoperDao storeoperDao) {
        this.storeoperDao = storeoperDao;
        super.setBaseDao(this.storeoperDao);
    }

    public void setEmpDao(IEmpDao empDao) {
        this.empDao = empDao;
    }

    public void setStoreDao(IStoreDao storeDao) {
        this.storeDao = storeDao;
    }

    public void setGoodsDao(IGoodsDao goodsDao) {
        this.goodsDao = goodsDao;
    }

    @Override
    public List<Storeoper> getListByPage(Storeoper storeoper1, Storeoper storeoper2, Object param, int firstResult, int maxResults) {
        List<Storeoper> list = super.getListByPage(storeoper1, storeoper2, null, firstResult, maxResults);
        Map<Long, String> empNameMap = new HashMap<>();
        Map<Long, String> storeNameMap = new HashMap<>();
        Map<Long, String> goodsNameMap = new HashMap<>();
        for (Storeoper storeoper : list) {
            storeoper.setEmpName(empDao.getName(storeoper.getEmpuuid(), empNameMap, "getName"));
            storeoper.setStoreName(storeDao.getName(storeoper.getStoreuuid(), storeNameMap, "getName"));
            storeoper.setGoodsName(goodsDao.getName(storeoper.getGoodsuuid(), goodsNameMap, "getName"));
        }
        return list;
    }
}
